package com.shitou.shitousearch.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * class detail:
 *
 * @author 石头人
 */
@SuppressWarnings("all")
@Configuration
public class ElasticConfig {

    @Resource
    private SearchConfig searchConfig;

    @Bean("restHighLevelClient")
    public RestHighLevelClient restHighLevelClient() {
        return new RestHighLevelClient(RestClient.builder(
                HttpHost.create(searchConfig.getElesticSearchUrl())
        ));
    }
}
